﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

using Radar.Utils;

namespace Radar.Navigation
{
    internal class NavZone
    {

        public NavZone(int left, int top, int right, int bottom)
        {
            Links = new List<Link>();
            Waypoints = new List<Waypoint>();
            Left = left;
            Top = top;
            Right = right;
            Bottom = bottom;
        }

        public int GetWidth()
        {
            return Right - Left;
        }

        public int GetHeight()
        {
            return Bottom - Top; 
        }

        public Rectangle GetRectangle()
        {
            return new Rectangle(Left, Top, Right - Left, Bottom - Top);
        }

        internal void AddLinkAndWaypoints(Link link)
        {
            if (!Links.Contains(link))
            {
                Links.Add(link);
                if (!Waypoints.Contains(link.CornerA)) Waypoints.Add(link.CornerA);
                if (!Waypoints.Contains(link.CornerB)) Waypoints.Add(link.CornerB);
            }
        }

        public int Left { get; private set; }

        public int Top { get; private set; }

        public int Right { get; private set; }

        public int Bottom { get; private set; }

        public List<Link> Links;

        public List<Waypoint> Waypoints;

        public override string ToString()
        {
            return String.Format("{0},{1} - {2},{3}", Left, Top, Right, Bottom);
        }

    }
}